//
//  RegistrationViewController.m
//  YZZX
//
//  Created by Easaa on 15/6/2.
//  Copyright (c) 2015年 Easaa. All rights reserved.
//

#import "RegistrationViewController.h"
#import "RegistrationPro.h"

#import "NSString+XSZCommon.h"

@interface RegistrationViewController ()<UITextFieldDelegate>
{
    UITextField  *_nameXing;
    UITextField  *_nameMing;
    UITextField  *_eMail;

}

@end

@implementation RegistrationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"注册";
    
    
    
    self.view.backgroundColor =RGBCOLOR(233, 233, 233);
    
    UIView  *LoginViewBgView = [[UIView alloc]initWithFrame:CGRectMake(0, 10, Dev_ScreenWidth, 120)];
    LoginViewBgView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:LoginViewBgView];
    
    UIView  *LineViewBgView = [[UIView alloc]initWithFrame:CGRectMake(10, 39, Dev_ScreenWidth-10, 1)];
    LineViewBgView.backgroundColor = RGBCOLOR(233, 233, 233);
    [LoginViewBgView addSubview:LineViewBgView];
    
    UIView  *LineViewBgView0 = [[UIView alloc]initWithFrame:CGRectMake(10, 79, Dev_ScreenWidth-10, 1)];
    LineViewBgView0.backgroundColor = RGBCOLOR(233, 233, 233);
    [LoginViewBgView addSubview:LineViewBgView0];

    
    
    UILabel *labelTitleUser = [[UILabel alloc] initWithFrame:CGRectMake(10, 0,20, 40)];
    labelTitleUser.font = [UIFont boldSystemFontOfSize:15];         //UILabel的字体大小
    labelTitleUser.numberOfLines = 0;                               //必须定义这个属性，否则UILabel不会换行
    labelTitleUser.textAlignment = NSTextAlignmentLeft;             //文本对齐方式
    labelTitleUser.text =@"姓:";
    [LoginViewBgView addSubview:labelTitleUser];
    
    
    _nameXing =[[UITextField alloc]initWithFrame:CGRectMake(30, 0, Dev_ScreenWidth-60, 40)];
    _nameXing.tag =0;
    _nameXing.delegate =self;
    [_nameXing becomeFirstResponder];
    _nameXing.font = [UIFont systemFontOfSize:15];
    [LoginViewBgView addSubview:_nameXing];
    
    
    
    
    
    UILabel *labelTitleMassge = [[UILabel alloc] initWithFrame:CGRectMake(10, 40,20, 40)];
    labelTitleMassge.font = [UIFont boldSystemFontOfSize:15];           //UILabel的字体大小
    labelTitleMassge.numberOfLines = 0;                                 //必须定义这个属性，否则UILabel不会换行
    labelTitleMassge.textAlignment = NSTextAlignmentLeft;               //文本对齐方式
    //    labelTitleMassge.textColor = [UIColor grayColor];
    labelTitleMassge.text =@"名:";
    [LoginViewBgView addSubview:labelTitleMassge];
    
    
    
    _nameMing =[[UITextField alloc]initWithFrame:CGRectMake(30, 40, Dev_ScreenWidth-60, 40)];
    _nameMing.tag =0;
    _nameMing.delegate =self;
    _nameMing.font = [UIFont systemFontOfSize:15];
    //_nameMing.secureTextEntry = YES;  //密文
    // PassWordText.backgroundColor = [UIColor greenColor];
    [LoginViewBgView addSubview:_nameMing];
    
    
    
    
    
    
    UILabel *labeleMail = [[UILabel alloc] initWithFrame:CGRectMake(10, 80,50, 40)];
    labeleMail.font = [UIFont boldSystemFontOfSize:15];           //UILabel的字体大小
    labeleMail.numberOfLines = 0;                                 //必须定义这个属性，否则UILabel不会换行
    labeleMail.textAlignment = NSTextAlignmentLeft;               //文本对齐方式
    //    labelTitleMassge.textColor = [UIColor grayColor];
    labeleMail.text =@"email:";
    [LoginViewBgView addSubview:labeleMail];
    
    
    
    _eMail =[[UITextField alloc]initWithFrame:CGRectMake(60, 80, Dev_ScreenWidth-60, 40)];
    _eMail.tag =0;
    _eMail.delegate =self;
    _eMail.font = [UIFont systemFontOfSize:15];
    // PassWordText.backgroundColor = [UIColor greenColor];
    [LoginViewBgView addSubview:_eMail];

    
    
    
    
    
    
    UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
    bottomButton.tag = 2014 ;
    bottomButton.frame =CGRectMake(10,LoginViewBgView.bottom+40 ,Dev_ScreenWidth-20, 40);
    [bottomButton addTarget:self action:@selector(RequestHeadlLinesAndHeadImageDataFantion) forControlEvents:UIControlEventTouchUpInside];
    [bottomButton.layer setMasksToBounds:YES];
    [bottomButton.layer setCornerRadius:2]; //设置矩圆角半径
    [bottomButton.layer setBorderWidth:0];   //边框宽度
    [bottomButton setTitle:@"下一步" forState:UIControlStateNormal];
    [bottomButton setTintColor:[UIColor whiteColor]];
    bottomButton.backgroundColor =RGBCOLOR(252, 78, 125);
    [self.view addSubview:bottomButton];
    

    
    
    
  }




- (void)RequestHeadlLinesAndHeadImageDataFantion
{
    if(_nameXing.text.length<=0||_nameMing.text.length<=0||_eMail.text.length<=0)
    {
        UIAlertView  *AlertView = [[UIAlertView alloc]initWithTitle:@"提示"
                                                            message:@"请输入完整！"
                                                           delegate:self
                                                  cancelButtonTitle:@"确定"
                                                  otherButtonTitles:nil];
        
        AlertView.tag = 1024;
        [AlertView show];
        return;
        
    }else if (![_eMail.text isEmail])
    {
        UIAlertView  *AlertView = [[UIAlertView alloc]initWithTitle:@"提示"
                                                            message:@"请输入正确的邮箱！"
                                                           delegate:self
                                                  cancelButtonTitle:@"确定"
                                                  otherButtonTitles:nil];
        
        AlertView.tag = 1025;
        [AlertView show];
        return;
    }
    
    
    RegistrationPro  *RegisView =[[RegistrationPro alloc]init];
    RegisView.nameMing = _nameMing.text;
    RegisView.nameXing = _nameXing.text;
    RegisView.eMail = _eMail.text;
    [self.navigationController pushViewController:RegisView animated:YES];
    

}




-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField
{
    [theTextField resignFirstResponder];
    
    return YES;
}

@end
